//
//  EventPictureCell.m
//  Runone
//
//  Created by runone02 on 16/10/11.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "EventPictureCell.h"
#import "EventDetailModel.h"
#import "EventDealListModel.h"
#import "EventBaseInfoModel.h"
#import "Masonry.h"
#import "AppConstants.h"

@implementation EventPictureCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"cellID";
    id cell = [tableView dequeueReusableCellWithIdentifier:ID ];
    
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
        [self configLayout];
//        self.contentView.backgroundColor = [UIColor clearColor];
    }
    return self;
}



- (void) configUI {
    _circleIV = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, 10, 10)];
    _circleIV.image = [UIImage imageNamed:@"blue_point"];
    [self addSubview:_circleIV];
    
    _lineV = [[UIView alloc] init];
    _lineV.backgroundColor = [UIColor colorWithRed:(204/255.0) green:(204/255.0) blue:(204/255.0) alpha:0.8];
    _lineV.layer.cornerRadius = 2;
    [self addSubview:_lineV];
    
    _timeLabel = [[UILabel alloc] init];
    _timeLabel.font      = [UIFont systemFontOfSize:13];
    _timeLabel.textColor = kTextColor;
    [self addSubview:_timeLabel];
    
    _recordlabel = [[UILabel alloc] init];
    _recordlabel.font = [UIFont systemFontOfSize:13];
    //    _recordlabel.backgroundColor = [UIColor redColor];
    [self addSubview:_recordlabel];
    
    _dealLabel = [[UILabel alloc] init];
    _dealLabel.font = [UIFont systemFontOfSize:13];
    _dealLabel.numberOfLines = 0;
    [self addSubview:_dealLabel];
    
    _picView = [[PicturesView alloc] init];
    [self addSubview:_picView];
    
    _bottomV = [[UIView alloc] init];
    _bottomV.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:_bottomV];
}

- (void) configLayout {

}

- (void)setCellFrame:(EventCellFrame *)cellFrame {
    _cellFrame = cellFrame;
    
    _timeLabel.text        = _cellFrame.lModel.DealTime;
    if ([_cellFrame.lModel.DealDetail isEqualToString:@"(null)"] || [_cellFrame.lModel.DealDetail isEqualToString:@""] ) {
        _dealLabel.hidden = YES;
        
    }else {
        _dealLabel.hidden      = NO;
        _dealLabel.text        = _cellFrame.lModel.DealDetail;
    }
       _recordlabel.text      = _cellFrame.lModel.UpdateUserName;
    _picView.picturesArray = _cellFrame.lModel.PicturePath;
    
    [self configFrame];
}

- (void) configFrame {
    
    _circleIV.frame  = _cellFrame.circleIVFrame;
    
    _lineV.frame     = _cellFrame.lineVFrame;
    
    _timeLabel.frame = _cellFrame.timeFrame;
    
    _dealLabel.frame = _cellFrame.dealFrame;
    
    _recordlabel.frame = _cellFrame.recordFrame;
    
    _picView.frame   = _cellFrame.photoesFrame;
    
    _bottomV.frame   = _cellFrame.bottomVFrame;
}

-(void)prepareForReuse {
    [super prepareForReuse];
    _dealLabel.hidden = NO;
    _picView.hidden   = NO;
}


@end
